package org.dromara.tearoom.mapper;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.dromara.tearoom.domain.TerUser;
import org.dromara.tearoom.domain.vo.TerOrderRoomVo;
import org.dromara.tearoom.domain.vo.TerUserDayVo;
import org.dromara.tearoom.domain.vo.TerUserVo;
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 用户Mapper接口
 *
 * @author xch
 * @date 2025-03-29
 */
public interface TerUserMapper extends BaseMapperPlus<TerUser, TerUserVo> {

    @Select("SELECT  SUM(create_time >= CURDATE()) AS registered, SUM(last_login_at >= CURDATE()) AS onlineCount FROM ter_user")
    TerUserDayVo selectUserTaDayVo();

    @Select("SELECT SUM(create_time >= NOW() - INTERVAL #{daynum} DAY) AS registered,SUM(last_login_at >= NOW() - INTERVAL #{daynum} DAY) AS onlineCount FROM ter_user")
    TerUserDayVo selectUserMonth(@Param("daynum") Integer daynum);

    @Select("SELECT  SUM(create_time BETWEEN #{start} AND #{end}) AS registered,SUM(last_login_at BETWEEN #{start} AND #{end}) AS onlineCount FROM ter_user")
    TerUserDayVo selectUserStarAndEnd(@Param("start") String start , @Param("end") String end);
}
